package com.swt.controller;

import com.swt.common.utils.QiNiuYunUpFileUtils;
import com.swt.common.vo.ResponseVo;
import com.swt.domain.Cart;

import com.swt.domain.TbManageUser;
import com.swt.service.TbManageUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/tbmanageuser")
public class TbManageUserController {
    @Autowired
    public TbManageUserService tbManageUserService;
    @PostMapping ("/{count}/{size}")
    public ResponseVo pageTbManageUser(@PathVariable Integer count,
                                       @PathVariable Integer size,
                                       @RequestBody(required = false)TbManageUser user){
        return ResponseVo.SUCCESS(tbManageUserService.pageuser(count,size,user));

    }
    @DeleteMapping("/{id}")
    public ResponseVo deleteTbManageUser(@PathVariable String id){
        return tbManageUserService.delectUser(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @GetMapping("/{id}")
    public ResponseVo selectTbManageUserById(@PathVariable String id){
        return ResponseVo.SUCCESS(tbManageUserService.selectbyuserid(id));
    }
    @PostMapping
    public ResponseVo insertTbManageUser(@RequestBody TbManageUser s){
        return tbManageUserService.inserUser(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updateTbManageUser(@RequestBody TbManageUser s){
        return tbManageUserService.updateUser(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PostMapping("/upload")
    public ResponseVo upLoadUserImg(MultipartFile file){
        System.out.println(file);
        return QiNiuYunUpFileUtils.getUpLoad(file);
    }
}


